package com.wangju.chapter4.aspect;

import com.wangju.chapter4.aspect.validator.UserValidator;
import com.wangju.chapter4.aspect.validator.impl.UserValidatorImpl;
import org.aspectj.lang.annotation.*;

@Aspect
public class MyAspect {


    @DeclareParents(
            value= "com.wangju.chapter4.aspect.service.impl.UserServiceImpl",
            defaultImpl= UserValidatorImpl.class)
    public UserValidator userValidator;

    @Pointcut("execution(* com.wangju.chapter4.aspect.service.impl.UserServiceImpl.printUser(..))")
    public void pointCut() {

    }

    @Before("pointCut()")
    public void before() {
        System.out.println("before ......");
    }

    @After("pointCut()")
    public void after() {
        System.out.println("after ......");
    }


    @AfterReturning("pointCut()")
    public void afterReturning() {
        System.out.println("afterReturning ......");
    }

    @AfterThrowing("pointCut()")
    public void afterThrowing() {
        System.out.println("afterThrowing ......");
    }
}
